﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Data;
using WebApplication1.MSG;
namespace WebApplication1
{
   public class MedEq
    {
      



       











      
        public DataSet Log_List_By_Flag(string flag)
        {
            DataBase db = new DataBase();

            DataSet ds = new DataSet();

            string selectStr = "select  维护记录表.ID,维护记录表.Flag,维护记录表.任务Flag,维护记录表.图片数量, 维护记录表.音频数量,维护记录表.视频数量, 维护记录表.记录内容,Users.ChineseName,维护记录表.记录时间,维护记录表.记录类型, 维护记录表.所属医院 from 维护记录表 JOIN Users ON  convert(nvarchar(255),维护记录表.记录人)= convert(nvarchar(255),Users.ID) where convert(nvarchar(255),任务Flag)= '" + flag + "' order by ID desc";



            ds = db.RunProcReturnDS(selectStr);
            return ds;


        }


        public DataSet Task_list_All(string EQFlag)
        {
            DataBase db = new DataBase();

            DataSet ds = new DataSet();


            string selectStr = "select* FROM 任务表 WHERE convert(nvarchar(255),设备Flag)= '" + EQFlag + "' order by ID";
            ds = db.RunProcReturnDS(selectStr);
            return ds;


        }

       


        public string Add_Task_Log(string TaskFlag, string Content, string UserName, string AddTim)
        {
            string Flag = Guid.NewGuid().ToString();
            DataBase db = new DataBase();
            int result = db.RunProc("insert into 报修任务记录表(Flag,Task_Flag,记录内容,记录人,记录时间) values('" + Flag + "','" + TaskFlag + "','" + Content + "','" + UserName + "','" + AddTim + "')");
            return result.ToString();

        }
       




      


      

      


        public DataSet PM_Finish_HSP(string HospitalID)
        {
            DataBase db = new DataBase();

            DataSet ds = new DataSet();


            string selectStr = "select PM任务表.ID,设备表.设备名称,PM任务表.生成日期,PM任务表.是否完成,Depts.Name,Users.ChineseName FROM 设备表 JOIN PM任务表  ON  convert(nvarchar(255),PM任务表.EQFlag)=convert(nvarchar(255),设备表.Flag) JOIN Depts ON  convert(nvarchar(255),设备表.所属科室)=convert(nvarchar(255),Depts.ID) JOIN Users ON  convert(nvarchar(255),PM任务表.执行人ID)=convert(nvarchar(255),Users.ID)  WHERE  convert(nvarchar(255),PM任务表.是否完成)= '任务完成' and   convert(nvarchar(255),设备表.所属医院)= '" + HospitalID + "' order by PM任务表.ID";
            ds = db.RunProcReturnDS(selectStr);
            return ds;


        }



      

   

     

        public int Add_Task_Cost(string TaskFlag,string SpareCost,string RPCost,string OtherCost)
        {

            DataBase db = new DataBase();
            string t = DateTime.Now.ToShortDateString();

            int i = db.RunProc("insert into 费用表(任务Flag,配件费,维修费,其它费) values('" + TaskFlag + "','" + SpareCost + "','" + RPCost + "','" + OtherCost + "')");

            return i;
        }


        public string Task_Total_Cost_By_Task_Flag(string TaskFlag)
        {
            DataBase db = new DataBase();

            DataSet ds = new DataSet();

            string selectStr = "select 配件表.Price from 配件更换表  JOIN 配件表 ON  convert(nvarchar(255),配件更换表.配件Flag)= convert(nvarchar(255),配件表.Flag) where convert(nvarchar(255),配件更换表.任务Flag)= '" + TaskFlag + "' order by 配件更换表.ID desc";



            ds = db.RunProcReturnDS(selectStr);
            int SpareSum = 0;
            int RPCost = 0;
            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                SpareSum += Int32.Parse(ds.Tables[0].Rows[i][0].ToString());


            }

            string selectStr2 = "select 维修费,其它费 From 费用表 Where convert(nvarchar(255),任务Flag)='" + TaskFlag + "'";
            DataBase db2 = new DataBase();
            DataSet ds2 = new DataSet();

            ds2 = db2.RunProcReturnDS(selectStr2);
            if (ds2.Tables[0].Rows.Count > 0)
            {

                RPCost = Int32.Parse(ds2.Tables[0].Rows[0][0].ToString()) + Int32.Parse(ds2.Tables[0].Rows[0][1].ToString());


            }


            return (RPCost + SpareSum).ToString();




        }

        public string Task_Total_Cost_by_Month(string year, string month)
        {


            string lastmonth = (Int32.Parse(month) - 1).ToString();
            string nextmonth = (Int32.Parse(month) + 1).ToString();



            if (lastmonth.Length == 1)
                lastmonth = "0" + lastmonth;

            if (nextmonth.Length == 1)
                nextmonth = "0" + nextmonth;

            string last = year + lastmonth + "31";
            string next = year + nextmonth + "01";
            DataBase db = new DataBase();

            DataSet ds = new DataSet();

            string selectStr = "select Flag from 任务表 where convert(nvarchar(255),生成日期)> '" + last + "' AND convert(nvarchar(255),生成日期)< '" + next + "' order by ID desc";



            ds = db.RunProcReturnDS(selectStr);





            int TotalCost = 0;



            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {


                int Cost = 0;





                string selectStr2 = "select 配件费,维修费,其它费 From 费用表 Where convert(nvarchar(255),任务Flag)='" + ds.Tables[0].Rows[i][0] + "'";
                DataBase db2 = new DataBase();
                DataSet ds2 = new DataSet();

                ds2 = db2.RunProcReturnDS(selectStr2);
                if (ds2.Tables[0].Rows.Count > 0)
                {

                    Cost = Int32.Parse(ds2.Tables[0].Rows[0][0].ToString()) + Int32.Parse(ds2.Tables[0].Rows[0][1].ToString()) + Int32.Parse(ds2.Tables[0].Rows[0][2].ToString());


                }
                TotalCost = TotalCost + Cost;



            }

            return TotalCost.ToString();




        }
















        public string Update_Task_ClassAndEtc(string TaskFlag, string Class,string etc)
        {
            DataBase dbs = new DataBase();
            // string selectStr = "insert into 验证表 (token,time,用户ID) values('" + token + "','" + DateTime.Now + "','" + UserID + "')";
            string selectStr = "update 任务表 set 维护等级='" + Class + "',备注='"+etc+"'where Flag='" + TaskFlag + "'";
            dbs.RunProc(selectStr);
            dbs.Dispose();

            return "ok";

        }




        public string Update_Repair_Log(string Flag, string RP_Flag, string Photocount, string Voicecount, string Content,
            string Recordperson, string Recordtime, string Logtype, string Hospital)
        {
            DataBase dbs = new DataBase();
            string selectStr = "update 维护记录表 set 任务Flag='" + RP_Flag + "',图片数量='"
                + Photocount + "',音频数量='" + Voicecount + "',记录内容='" + Content + "',记录人='" + Recordperson
                + "',记录时间='" + Recordtime + "',记录类型='" + Logtype + "', 所属医院='" + Hospital + "' where Flag='" + Flag + "'AND convert(nvarchar(255),所属医院)= '" + Hospital + "'";
            string result = dbs.RunProc(selectStr).ToString();
            dbs.Dispose();

            return result;


        }

        /// <summary>
        /// 更新设备信息
        /// </summary>
        /// <param name="flag"></param>
        /// <param name="EQNr"></param>
        /// <param name="name"></param>
        /// <param name="SrNr"></param>
        /// <param name="Type"></param>
        /// <param name="Factory"></param>
        /// <param name="Distributor"></param>
        /// <param name="Prise"></param>
        /// <param name="BuyDate"></param>
        /// <param name="Department"></param>
        /// <param name="Hospital"></param>
        /// <param name="EQType"></param>
        /// <param name="AssetsType"></param>
        /// <param name="FctEngineerID"></param>
        /// <param name="HspEngineerID"></param>
        /// <param name="Admin"></param>
        /// <param name="Service_TEL"></param>
        /// <param name="Remarks"></param>
        /// <returns></returns>
        public string Update_EQ_Info(string flag, string EQNr, string name, string SrNr, string Type, string Factory, string Distributor, string Prise, string BuyDate, string Department, string Hospital, string EQType, string AssetsType
            , string FctEngineerID, string HspEngineerID, string Admin, string Service_TEL, string Remarks, string Dept_Admin,string measurement)
        {
            if (EQNr.Equals(""))
                EQNr = "无";
            if (name.Equals(""))
                name = "无";           //设备名称

            if (SrNr.Equals(""))
                SrNr = "无";
            if (Type.Equals(""))
                Type = "无";
            if (Factory.Equals(""))
                Factory = "无";
            if (Distributor.Equals(""))
                Distributor = "无";

            if (Prise.Equals(""))

                Prise = "0";
            if (BuyDate.Equals(""))
                BuyDate = "无";
            if (Department.Equals(""))
                Department = "无";
            if (Hospital.Equals(""))
                Hospital = "无";
            if (EQType.Equals(""))

                EQType = "无";
            if (AssetsType.Equals(""))
                AssetsType = "无";
            if (FctEngineerID.Equals(""))

                FctEngineerID = "无";
            if (HspEngineerID.Equals(""))
                HspEngineerID = "无";
            if (Admin.Equals(""))
                Admin = "无";
            if (Service_TEL.Equals(""))
                Service_TEL = "无";
            if (Remarks.Equals(""))
                Remarks = "无";
            DataBase dbs = new DataBase();
            string selectStr = "update 设备表 set 设备编号='" + EQNr + "',设备名称='"
                + name + "',出厂编号='" + SrNr + "',设备型号='" + Type + "',生产厂商='" + Factory
                + "',经销商='" + Department + "',购入价格='" + Prise + "', 购入日期='" + BuyDate + "', 所属科室='" + Department + "',所属医院='" + Hospital + "',设备类型='" + EQType
                + "',资产类型='" + AssetsType + "',厂商工程师='" + FctEngineerID + "',医院工程师='"
                + HspEngineerID + "',设备负责人='" + Admin + "',售后电话='" + Service_TEL + "',备注='" + Remarks + "',管理科室='" + Dept_Admin + "',计量标识='" + measurement + "' where Flag='" + flag + "'";
            string result = dbs.RunProc(selectStr).ToString();
            dbs.Dispose();

            return result;

        }
        public DataSet EQ_Meas_Cer_List(string EQFlag)
        {
            DataBase db = new DataBase();

            DataSet ds = new DataSet();


            string selectStr = "select ID,文件名,文件描述,上传时间  FROM 设备证书表 WHERE convert(nvarchar(255),设备Flag)= '" + EQFlag + "'and  convert(nvarchar(255),删除标识)= '0'and  convert(nvarchar(255),文件描述) Like  '%'+'计量证书'+'%' order by ID";
            ds = db.RunProcReturnDS(selectStr);
            return ds;


        }


        public DataSet DEL_EQ_Cer_By_Flag(string CerID)
        {
            DataBase db = new DataBase();

            DataSet ds = new DataSet();

            string selectStr = "delete from 设备证书表 where ID='" + CerID + "'";
          
            ds = db.RunProcReturnDS(selectStr);
            return ds;


        }



        public int Add_Task_image(string TaskFlag, string filename)
        {

            DataBase db = new DataBase();
            string t = DateTime.Now.ToShortDateString();

            int i = db.RunProc("insert into 报修任务图片表(任务Flag,文件名,上传时间) values('" + TaskFlag + "','" + filename + "','" + t + "')");

            return i;
        }

        public DataSet DEL_EQ_photo_By_Flag(string ID)
        {
            DataBase db = new DataBase();

            DataSet ds = new DataSet();

            string selectStr = "delete from 设备图片表 where ID='" + ID + "'";
          
            ds = db.RunProcReturnDS(selectStr);
            return ds;


        }






       
      
        public string Update_Token(string UserID, string token)
        {
            DataBase dbs = new DataBase();
            // string selectStr = "insert into 验证表 (token,time,用户ID) values('" + token + "','" + DateTime.Now + "','" + UserID + "')";
            string selectStr = "update 用户表 set Token='" + token + "'where 用户ID='" + UserID + "'";
            dbs.RunProc(selectStr);
            dbs.Dispose();

            return "ok";

        }

        public string Finish_Task(string TaskFlag)
        {

            DataBase db = new DataBase();
            db.RunProc("update 任务表 set 维修进程 ='任务完成' where Flag='" + TaskFlag + "'");
            return "ok";

        }



        public string Change_Task_State(string TaskFlag,string State)
        {

            DataBase db = new DataBase();
            db.RunProc("update 报修任务表 set 维修进程 ='" + State + "' where Flag='" + TaskFlag + "'");

            string selectStr = "select 报修人微信UserID from 报修任务表 where Flag='" + TaskFlag + "'";
            DataSet ds = new DataSet();
            ds = db.RunProcReturnDS(selectStr);
            if (ds.Tables[0].Rows.Count > 0)
            {
                string id = ds.Tables[0].Rows[0][0].ToString();
                if (id.Length > 2)
                {
                    SendMSG sd = new SendMSG();
                    sd.Send(id, "您的报修任务状态已更新：" + State);
                }
            
            }
            return "ok";

        }
       

        public string Change_Task_HSPEGN(string TaskFlag, string HSPEGNID)
        {

            DataBase db = new DataBase();
            db.RunProc("update 报修任务表 set 执行人 ='" + HSPEGNID + "' where Flag='" + TaskFlag + "'");
            return "ok";

        }
       
        public string Add_Task(string Flag, string EQFlag, string Describe, string FaultCode, string CallPerson, string CallTime, string AnswerTime, string TaskPersonID, string Progress, string PictureCount, string VoiceCount, string VideoCount, string Department, string Hospital, string Type, string Repair_Cost)
        {
            DateTime TD = DateTime.Now;
            string mtyear = TD.Year.ToString();
            string mtmonth = null;
            string mtday = null;
            mtmonth = TD.Month.ToString();
            mtday = TD.Day.ToString();
            if (TD.Month.ToString().Length == 1)
                mtmonth = "0" + TD.Month.ToString();

            if (TD.Day.ToString().Length == 1)
                mtday = "0" + TD.Day.ToString();

            String Today = mtyear + mtmonth + mtday;
            DataBase db = new DataBase();

            int i = db.RunProc("insert into 报修任务表 (Flag,设备Flag,故障描述,故障代码,报修人,报修时间,回应时间,执行人,维修进程,图片数量,音频数量,视频数量,所属科室,所属医院,任务类别,维修费,生成日期) values('" + Flag + "','" + EQFlag + "','" + Describe + "','" + FaultCode + "','" + CallPerson + "','" + CallTime + "','" + AnswerTime + "','" + TaskPersonID + "','" + Progress + "','" + PictureCount + "','" + VoiceCount + "','" + VideoCount + "','" + Department + "','" + Hospital + "','" + Type + "','" + Repair_Cost + "','" + Today + "')");

            return i.ToString();
        }


        
       







        public DataSet EGN_List()
        {
            DataBase db = new DataBase();

            DataSet ds = new DataSet();

            string selectStr = "select ID,ChineseName,WeChat from Users  where convert(nvarchar(255),Remark)= '工程师' or convert(nvarchar(255),Remark)= '总工程师'";



            ds = db.RunProcReturnDS(selectStr);
            return ds;


        }



        public DataSet EQlistLikeNameByDeps(string name, string department)
        {
            DataBase db = new DataBase();

            DataSet ds = new DataSet();

           // string selectStr = "select ID,资产编号,设备名称,设备型号,出厂编号,设备类别,生产厂家,购买日期,厂商工程师,医院工程师,图片标识,备注,所属医院 from 设备表 where convert(nvarchar(255),设备名称)LIKE '%'+'" + name + "'+'%'AND convert(nvarchar(255),所属科室)= '" + department + "'";

            string selectStr = "select  设备表.Flag,设备表.设备编号,设备表.设备名称,设备表.出厂编号,设备表.设备型号,设备表.生产厂商,设备表.购入日期,设备表.医院工程师,Users.ChineseName from 设备表 JOIN Users ON  convert(nvarchar(255),设备表.医院工程师)=convert(nvarchar(255),Users.ID) where convert(nvarchar(255),设备表.设备名称)LIKE '%'+'" + name + "'+'%'AND convert(nvarchar(255),设备表.所属科室)= '" + department + "' AND convert(nvarchar(255),设备表.删除标识)= '0'";



            ds = db.RunProcReturnDS(selectStr);
            return ds;


        }

        public DataSet EQlistLikeNameByHSP(string name, string HSPID)
        {
            DataBase db = new DataBase();

            DataSet ds = new DataSet();

           // string selectStr = "select ID,资产编号,设备名称,设备型号,出厂编号,设备类别,生产厂家,购买日期,厂商工程师,医院工程师,图片标识,备注,所属医院 from 设备表 where convert(nvarchar(255),设备名称)LIKE '%'+'" + name + "'+'%'AND convert(nvarchar(255),所属医院)= '" + HSPID + "'";

            string selectStr = "select 设备表.Flag,设备表.设备编号,设备表.设备名称,设备表.出厂编号,设备表.设备型号,设备表.生产厂商,设备表.购入日期,Users.ChineseName from 设备表 JOIN Users ON  convert(nvarchar(255),设备表.医院工程师)=convert(nvarchar(255),Users.ID) where convert(nvarchar(255),设备表.设备名称)LIKE '%'+'" + name + "'+'%'AND convert(nvarchar(255),设备表.所属医院)= '" + HSPID + "'AND convert(nvarchar(255),设备表.删除标识)= '0'";



            ds = db.RunProcReturnDS(selectStr);
            return ds;


        }




        public DataSet EQ_List_Engineer_HSP(string Engineer_HSP)
        {
            DataBase db = new DataBase();

            DataSet ds = new DataSet();

            string selectStr = "select ID,资产编号,设备名称,设备型号,出厂编号,设备类别,生产厂家,购买日期,厂商工程师,医院工程师,图片标识,备注,所属医院 from 设备表 where convert(nvarchar(255),医院工程师)='" + Engineer_HSP + "' AND convert(nvarchar(255),设备表.删除标识)= '0'";



            ds = db.RunProcReturnDS(selectStr);
            return ds;


        }


        public DataSet EQ_List_HSP(string HSPID)
        {
            DataBase db = new DataBase();

            DataSet ds = new DataSet();

            string selectStr = "select 设备表.Flag,设备表.设备编号,设备表.设备名称,设备表.出厂编号,设备表.设备型号,设备表.生产厂商,设备表.购入日期,Users.ChineseName from 设备表 JOIN Users ON  convert(nvarchar(255),设备表.医院工程师)=convert(nvarchar(255),Users.ID) where convert(nvarchar(255),设备表.所属医院)= '" + HSPID + "' AND convert(nvarchar(255),设备表.删除标识)= '0'";



            ds = db.RunProcReturnDS(selectStr);
            return ds;


        }




    
      
        /// <summary>
        /// ///////////////////////////////////////////////////////////////////////
        /// </summary>
        /// <param name="department"></param>
        /// <param name="hospital"></param>
        /// <returns></returns>














        public DataSet EQ_Info_By_EQFlag_And_HSP(string flag)
        {
            DataBase db = new DataBase();

            DataSet ds = new DataSet();

            string selectStr = "select  * from 设备表 where convert(nvarchar(255),Flag)= '" + flag + "'";



            ds = db.RunProcReturnDS(selectStr);
            return ds;


        }

        public DataSet Repair_Log_Info_By_Flag_And_HSP(string flag, string hospital)
        {
            DataBase db = new DataBase();

            DataSet ds = new DataSet();

            string selectStr = "select  * from 维护记录表 where convert(nvarchar(255),Flag)= '" + flag + "' and convert(nvarchar(255),所属医院)= '" + hospital + "'";



            ds = db.RunProcReturnDS(selectStr);
            return ds;


        }


   















        /// <summary>
        /// RepairLog
        /// </summary>
        /// <param name="Flag"></param>
        /// <param name="RP_Flag"></param>
        /// <param name="photocount"></param>
        /// <param name="voicecount"></param>
        /// <param name="content"></param>
        /// <param name="recordperson"></param>
        /// <param name="recordtime"></param>
        /// <param name="logtype"></param>
        /// <param name="hospital"></param>
        /// <returns></returns>




        public string Add_Repair_Log(string Flag, string RP_Flag, string photocount, string voicecount, string content, string recordperson, string recordtime, string logtype, string hospital)
        {

            DataBase db = new DataBase();


            int result = db.RunProc("insert into 维护记录表 (Flag,任务Flag,图片数量,音频数量,记录内容,记录人,记录时间,记录类型,所属医院) values('" + Flag + "','" + RP_Flag + "','" + photocount + "','" + voicecount + "','" + content + "','" + recordperson + "','" + recordtime + "','" + logtype + "','" + hospital + "')");

            return result.ToString();

        }
        /// <summary>
        /// PMlog
        /// </summary>
        /// <param name="Flag"></param>
        /// <param name="RP_Flag"></param>
        /// <param name="photocount"></param>
        /// <param name="voicecount"></param>
        /// <param name="content"></param>
        /// <param name="recordperson"></param>
        /// <param name="recordtime"></param>
        /// <param name="logtype"></param>
        /// <param name="hospital"></param>
        /// <returns></returns>
   

        /// <summary>
        /// 添加设备
        /// </summary>
        /// <param name="flag"></param>
        /// <param name="EQNr"></param>
        /// <param name="name"></param>
        /// <param name="SrNr"></param>
        /// <param name="Type"></param>
        /// <param name="Factory"></param>
        /// <param name="Distributor"></param>
        /// <param name="Price"></param>
        /// <param name="BuyDate"></param>
        /// <param name="Department"></param>
        /// <param name="Hspital"></param>
        /// <param name="EQType"></param>
        /// <param name="AssetsType"></param>
        /// <param name="FctEngineerID"></param>
        /// <param name="HspEngineerID"></param>
        /// <param name="Admin"></param>
        /// <param name="Service_TEL"></param>
        /// <param name="Remarks"></param>
        /// <param name="ImageCount"></param>
        /// <param name="Location"></param>
        /// <param name="Measurement_Flag"></param>
        /// <returns></returns>

        public int AddEQ(string flag, string EQNr, string name, string SrNr, string Type, string Factory, string Distributor, string Price, string BuyDate, string Department, string Hspital, string EQType, string AssetsType, string FctEngineerID, string HspEngineerID, string Admin, string Service_TEL, string Remarks, string ImageCount, string Location, string Measurement_Flag)
        {

            if (flag.Equals(""))
                flag = "无";
            if (EQNr.Equals(""))
                EQNr = "无";
            if (name.Equals(""))
                name = "无";           //设备名称

            if (SrNr.Equals(""))
                SrNr = "无";
            if (Type.Equals(""))
                Type = "无";
            if (Factory.Equals(""))
                Factory = "无";
            if (Distributor.Equals(""))
                Distributor = "无";

            if (Price.Equals(""))

                Price = "0";
            if (BuyDate.Equals(""))
                BuyDate = "无";
            if (Department.Equals(""))
                Department = "无";
            if (Hspital.Equals(""))
                Hspital = "无";
            if (EQType.Equals(""))

                EQType = "无";
            if (AssetsType.Equals(""))
                AssetsType = "无";
            if (FctEngineerID.Equals(""))

                FctEngineerID = "无";
            if (HspEngineerID.Equals(""))
                HspEngineerID = "无";
            if (Admin.Equals(""))
                Admin = "无";
            if (Service_TEL.Equals(""))
                Service_TEL = "无";
            if (Remarks.Equals(""))
                Remarks = "无";



            DataBase db = new DataBase();
            return db.RunProc("insert into 设备表 (Flag,设备编号,设备名称,出厂编号,设备型号,生产厂商,经销商,购入价格,购入日期,所属科室,所属医院,设备类型,资产类型,厂商工程师,医院工程师,设备负责人,售后电话,备注,图片数量,存放位置,计量标识) values('" + flag + "','" + EQNr + "','" + name + "','" + SrNr + "','" + Type + "','" + Factory + "','" + Distributor + "','" + Price + "','" + BuyDate + "','" + Department + "','" + Hspital + "','" + EQType + "','" + AssetsType + "','" + FctEngineerID + "','" + HspEngineerID + "','" + Admin + "','" + Service_TEL + "','" + Remarks + "' ,'" + ImageCount + "','" + Location + "','" + Measurement_Flag + "')");
        }

        public int AddEQ_Full(string flag, string EQNr, string name, string SrNr, string Type, string Factory, string Distributor, string Price, string BuyDate, string Department, string Hspital, string EQType, string AssetsType, string FctEngineerID, string HspEngineerID, string Admin, string Service_TEL, string Remarks, string Location, string Measurement_Flag, string PM_Next, string PM_Period, string Admin_Department, string Room)
        {

            if (flag.Equals(""))
                flag = "无";
            if (EQNr.Equals(""))
                EQNr = "无";
            if (name.Equals(""))
                name = "无";           //设备名称

            if (SrNr.Equals(""))
                SrNr = "无";
            if (Type.Equals(""))
                Type = "无";
            if (Factory.Equals(""))
                Factory = "无";
            if (Distributor.Equals(""))
                Distributor = "无";

            if (Price.Equals(""))

                Price = "0";
            if (BuyDate.Equals(""))
                BuyDate = "无";
            if (Department.Equals(""))
                Department = "无";
            if (Hspital.Equals(""))
                Hspital = "无";
            if (EQType.Equals(""))

                EQType = "无";
            if (AssetsType.Equals(""))
                AssetsType = "无";
            if (FctEngineerID.Equals(""))

                FctEngineerID = "无";
            if (HspEngineerID.Equals(""))
                HspEngineerID = "无";
            if (Admin.Equals(""))
                Admin = "无";
            if (Service_TEL.Equals(""))
                Service_TEL = "无";
            if (Remarks.Equals(""))
                Remarks = "无";
            if (Remarks.Equals(""))
                Remarks = "无";

            if (Location.Equals(""))
                Location = "无";
            if (Measurement_Flag.Equals(""))
                Measurement_Flag = "否";
            if (PM_Next.Equals(""))
                PM_Next = "无";
            if (PM_Period.Equals(""))
                PM_Period = "0";

            if (Admin_Department.Equals(""))
                Admin_Department = "无";
            if (Room.Equals(""))
                Room = "无";

            DataBase db = new DataBase();
            return db.RunProc("insert into 设备表 (Flag,设备编号,设备名称,出厂编号,设备型号,生产厂商,经销商,购入价格,购入日期,所属科室,所属医院,设备类型,资产类型,厂商工程师,医院工程师,设备负责人,售后电话,备注,存放位置,计量标识,下次PM日期,PM周期,管理科室,机房ID) values('" + flag + "','" + EQNr + "','" + name + "','" + SrNr + "','" + Type + "','" + Factory + "','" + Distributor + "','" + Price + "','" + BuyDate + "','" + Department + "','" + Hspital + "','" + EQType + "','" + AssetsType + "','" + FctEngineerID + "','" + HspEngineerID + "','" + Admin + "','" + Service_TEL + "','" + Remarks + "','" + Location + "','" + Measurement_Flag + "','" + PM_Next + "','" + PM_Period + "','" + Admin_Department + "','" + Room + "')");
        }


        public void AddEQ_Other(string name, string number, string srnumber, string type, string factory, string buydate, string department, string hospital, string eqtype, string dmperiod, string facengineer, string hspengineer, string picture, string other, string ImageCount)
        {

            DataBase db = new DataBase();


            db.RunProc("insert into 其它设备表 (设备名称,资产编号,出厂编号,设备型号,生产厂家,购买日期,所属科室,所属医院,设备类别,DM周期,厂商工程师,医院工程师,图片标识,备注,图片数量) values('" + name + "','" + number + "','" + srnumber + "','" + type + "','" + factory + "','" + buydate + "','" + department + "','" + hospital + "','" + eqtype + "','" + dmperiod + "','" + facengineer + "','" + hspengineer + "','" + picture + "','" + other + "','" + ImageCount + "')");
        }

















        public DataSet RPlistByCallPerson(string username)
        {
            DataBase db = new DataBase();

            DataSet ds = new DataSet();


            string selectStr = "select 任务表.ID,任务表.报修编号,设备表.设备名称,设备表.资产编号,设备表.出厂编号,设备表.设备型号,设备表.生产厂家,设备表.所属科室,设备表.购买日期,设备表.医院工程师,设备表.厂商工程师,任务表.故障描述,任务表.报修时间,任务表.维修进程,任务表.图片数量 FROM 设备表 JOIN 任务表 ON  convert(nvarchar(255),任务表.资产编号)=convert(nvarchar(255),设备表.资产编号) WHERE convert(nvarchar(255),任务表.报修人)= '" + username + "'AND convert(nvarchar(255),任务表.维修进程)!= '完成' order by 任务表.ID desc";

            ds = db.RunProcReturnDS(selectStr);
            return ds;


        }

        public DataSet PM_Option_List()
        {
            DataBase db = new DataBase();

            DataSet ds = new DataSet();


            string selectStr = "select *  FROM PM项目表";

            ds = db.RunProcReturnDS(selectStr);
            return ds;


        }
        public DataSet PM_Template_List()
        {
            DataBase db = new DataBase();

            DataSet ds = new DataSet();


            string selectStr = "select *  FROM PM模板表";

            ds = db.RunProcReturnDS(selectStr);
            return ds;


        }

        public DataSet PM_Template_Item(string TID)
        {
            DataBase db = new DataBase();

            DataSet ds = new DataSet();


            string selectStr = "select PM模板项目表.ID,PM项目表.项目,PM模板项目表.工时,PM模板项目表.难度,PM模板项目表.内容 FROM PM模板项目表 Join PM项目表 ON  convert(nvarchar(255),PM项目表.ID)=convert(nvarchar(255),PM模板项目表.项目ID) where 模板ID='" + TID + "'";

            ds = db.RunProcReturnDS(selectStr);
            return ds;


        }



        public string DEL_Template_Item_By_ID(string TID)
        {

            DataBase dbs = new DataBase();
            string selectStr = "Delete PM模板项目表 where ID='" + TID + "'";
            string result = dbs.RunProc(selectStr).ToString();
            dbs.Dispose();
            return result;

            return null;

        }












        public string DEL_PM_Option(string ID)
        {

            DataBase dbs = new DataBase();
            string selectStr = "delete from PM项目表 where ID='"+ID+"'";
            string result = dbs.RunProc(selectStr).ToString();
            dbs.Dispose();
            return result;

            

        }
        public void Add_PM_Option(string option)
        {

            DataBase dbs = new DataBase();
            string selectStr = "Insert into PM项目表(项目) values('"+option+"')";
            dbs.RunProc(selectStr).ToString();
          



        }

        public void Add_PM_T_Item(string TID,string optionID,string wtime,string hard,string content,string period)
        {

            DataBase dbs = new DataBase();
            string selectStr = "Insert into PM模板项目表(模板ID,项目ID,工时,难度,内容,周期) values('"+TID+"','" + optionID + "','" + wtime + "','" + hard + "','" + content + "','"+period+"')";
            dbs.RunProc(selectStr).ToString();




        }
       



        public DataSet RPlist_Egineer(string username)
        {
            DataBase db = new DataBase();

            DataSet ds = new DataSet();


            string selectStr = "select 任务表.ID,任务表.报修编号,设备表.设备名称,设备表.资产编号,设备表.出厂编号,设备表.设备型号,设备表.生产厂家,设备表.所属科室,设备表.购买日期,设备表.医院工程师,设备表.厂商工程师,任务表.故障描述,任务表.报修时间,任务表.维修进程,任务表.图片数量 FROM 设备表 JOIN 任务表 ON  convert(nvarchar(255),任务表.资产编号)=convert(nvarchar(255),设备表.资产编号) WHERE convert(nvarchar(255),设备表.医院工程师)= '" + username + "'AND convert(nvarchar(255),任务表.维修进程)!= '完成' order by 任务表.ID";
            ds = db.RunProcReturnDS(selectStr);
            return ds;


        }









        public DataSet RPlist_All()
        {
            DataBase db = new DataBase();
            DataBase db2 = new DataBase();
            DataSet ds = new DataSet();
            DataSet dstemp = new DataSet();




            string selectStr = "select 设备表.设备名称,报修任务表.故障描述,报修任务表.报修时间,报修任务表.维修进程,User2.ChineseName,Depts.Name,报修任务表.报修人,报修任务表.Flag,Dept2.Name FROM  报修任务表  JOIN Depts  ON  convert(nvarchar(255),报修任务表.所属科室)=convert(nvarchar(255),Depts.DeptNumber) JOIN Depts Dept2 ON  convert(nvarchar(255),Depts.PID)= convert(nvarchar(255),Dept2.DeptNumber) JOIN Users as User2  ON  convert(nvarchar(255),报修任务表.执行人)=convert(nvarchar(255),User2.ID)  JOIN 设备表  ON  convert(nvarchar(255),设备表.Flag)=convert(nvarchar(255),报修任务表.设备Flag)   WHERE  convert(nvarchar(255),报修任务表.维修进程)!= '任务完成' order by 报修任务表.ID desc";

            ds = db.RunProcReturnDS(selectStr);
            ds.Tables[0].Columns[4].ColumnName = "执行人";
            ds.Tables[0].Columns[5].ColumnName = "报修科室";
            ds.Tables[0].Columns[6].ColumnName = "报修人";
            ds.Tables[0].Columns[8].ColumnName = "报修学院";


          




            return ds;


        }

        public DataSet RPlist_UnFinish()
        {
            DataBase db = new DataBase();
            DataBase db2 = new DataBase();
            DataSet ds = new DataSet();
            DataSet dstemp = new DataSet();




            string selectStr = "select 设备表.设备名称,报修任务表.故障描述,报修任务表.报修时间,报修任务表.维修进程,User2.ChineseName,Depts.Name,报修任务表.报修人,报修任务表.Flag,Dept2.Name FROM  报修任务表  JOIN Depts  ON  convert(nvarchar(255),报修任务表.所属科室)=convert(nvarchar(255),Depts.DeptNumber) JOIN Depts Dept2 ON  convert(nvarchar(255),Depts.PID)= convert(nvarchar(255),Dept2.DeptNumber) JOIN Users as User2  ON  convert(nvarchar(255),报修任务表.执行人)=convert(nvarchar(255),User2.ID)  JOIN 设备表  ON  convert(nvarchar(255),设备表.Flag)=convert(nvarchar(255),报修任务表.设备Flag)   WHERE  convert(nvarchar(255),报修任务表.维修进程)!= '任务完成' AND convert(nvarchar(255),报修任务表.维修进程)!= '等待回应' order by 报修任务表.ID desc";

            ds = db.RunProcReturnDS(selectStr);
            ds.Tables[0].Columns[4].ColumnName = "执行人";
            ds.Tables[0].Columns[5].ColumnName = "报修科室";
            ds.Tables[0].Columns[6].ColumnName = "报修人";
            ds.Tables[0].Columns[8].ColumnName = "报修学院";







            return ds;


        }
        public DataSet RPlist_Finished()
        {
            DataBase db = new DataBase();
            DataBase db2 = new DataBase();
            DataSet ds = new DataSet();
            DataSet dstemp = new DataSet();




            string selectStr = "select 设备表.设备名称,报修任务表.故障描述,报修任务表.报修时间,报修任务表.维修进程,User2.ChineseName,Depts.Name,报修任务表.报修人,报修任务表.Flag,Dept2.Name FROM  报修任务表  JOIN Depts  ON  convert(nvarchar(255),报修任务表.所属科室)=convert(nvarchar(255),Depts.DeptNumber) JOIN Depts Dept2 ON  convert(nvarchar(255),Depts.PID)= convert(nvarchar(255),Dept2.DeptNumber) JOIN Users as User2  ON  convert(nvarchar(255),报修任务表.执行人)=convert(nvarchar(255),User2.ID)  JOIN 设备表  ON  convert(nvarchar(255),设备表.Flag)=convert(nvarchar(255),报修任务表.设备Flag)   WHERE  convert(nvarchar(255),报修任务表.维修进程)= '任务完成'  order by 报修任务表.ID desc";

            ds = db.RunProcReturnDS(selectStr);
            ds.Tables[0].Columns[4].ColumnName = "执行人";
            ds.Tables[0].Columns[5].ColumnName = "报修科室";
            ds.Tables[0].Columns[6].ColumnName = "报修人";
            ds.Tables[0].Columns[8].ColumnName = "报修学院";







            return ds;


        }
        public DataSet RPlist_Unreply()
        {
            DataBase db = new DataBase();
            DataBase db2 = new DataBase();
            DataSet ds = new DataSet();
            DataSet dstemp = new DataSet();




            string selectStr = "select 设备表.设备名称,报修任务表.故障描述,报修任务表.报修时间,报修任务表.维修进程,User2.ChineseName,Depts.Name,报修任务表.报修人,报修任务表.Flag,Dept2.Name FROM  报修任务表  JOIN Depts  ON  convert(nvarchar(255),报修任务表.所属科室)=convert(nvarchar(255),Depts.DeptNumber) JOIN Depts Dept2 ON  convert(nvarchar(255),Depts.PID)= convert(nvarchar(255),Dept2.DeptNumber) JOIN Users as User2  ON  convert(nvarchar(255),报修任务表.执行人)=convert(nvarchar(255),User2.ID)  JOIN 设备表  ON  convert(nvarchar(255),设备表.Flag)=convert(nvarchar(255),报修任务表.设备Flag)   WHERE  convert(nvarchar(255),报修任务表.维修进程)= '等待回应' order by 报修任务表.ID desc";

            ds = db.RunProcReturnDS(selectStr);
            ds.Tables[0].Columns[4].ColumnName = "执行人";
            ds.Tables[0].Columns[5].ColumnName = "报修科室";
            ds.Tables[0].Columns[6].ColumnName = "报修人";
            ds.Tables[0].Columns[8].ColumnName = "报修学院";







            return ds;


        }

        public DataSet Apply_List_Chief()
        {
            DataBase db = new DataBase();
            DataBase db2 = new DataBase();
            DataSet ds = new DataSet();
            DataSet dstemp = new DataSet();




            string selectStr = "select 设备表.设备名称,报修任务表.故障描述,报修任务表.维修进程,报修任务表.报修人,报修任务表.Flag,报修任务表.申请人,convert(nvarchar(255),报修任务表.市场价格) as 市场价格,convert(nvarchar(255),报修任务表.维修预算) as 维修预算,报修任务表.预算附言,报修任务表.Flag FROM  报修任务表  JOIN Depts  ON  convert(nvarchar(255),报修任务表.所属科室)=convert(nvarchar(255),Depts.DeptNumber) JOIN Users as User2  ON  convert(nvarchar(255),报修任务表.执行人)=convert(nvarchar(255),User2.ID)  JOIN 设备表  ON  convert(nvarchar(255),设备表.Flag)=convert(nvarchar(255),报修任务表.设备Flag)   WHERE  convert(nvarchar(255),报修任务表.审批意见)!='同意'  and  convert(nvarchar(255),报修任务表.审批意见)!='无需审批' order by 报修任务表.ID desc";

            ds = db.RunProcReturnDS(selectStr);
           







            return ds;


        }
        public DataSet Apply_List_Director()
        {
            DataBase db = new DataBase();
            DataBase db2 = new DataBase();
            DataSet ds = new DataSet();
            DataSet dstemp = new DataSet();




            string selectStr = "select 设备表.设备名称,报修任务表.故障描述,报修任务表.维修进程,报修任务表.报修人,报修任务表.Flag,报修任务表.申请人,convert(nvarchar(255),报修任务表.市场价格) as 市场价格,convert(nvarchar(255),报修任务表.维修预算) as 维修预算,报修任务表.预算附言,报修任务表.Flag FROM  报修任务表  JOIN Depts  ON  convert(nvarchar(255),报修任务表.所属科室)=convert(nvarchar(255),Depts.DeptNumber) JOIN Users as User2  ON  convert(nvarchar(255),报修任务表.执行人)=convert(nvarchar(255),User2.ID)  JOIN 设备表  ON  convert(nvarchar(255),设备表.Flag)=convert(nvarchar(255),报修任务表.设备Flag)   WHERE  convert(nvarchar(255),报修任务表.审批意见) ='等待上级审批' order by 报修任务表.ID desc";

            ds = db.RunProcReturnDS(selectStr);








            return ds;


        }
        public DataSet Dept_List(string PID)
        {
            DataBase db = new DataBase();
            DataBase db2 = new DataBase();
            DataSet ds = new DataSet();
            DataSet dstemp = new DataSet();




            string selectStr = "select Name,DeptNumber from Depts  WHERE  convert(nvarchar(255),PID)= '" + PID + "'and Name!='未知部门' and Name!='维修中心'";

            ds = db.RunProcReturnDS(selectStr);
            

            return ds;


        }

        public DataSet GetUserInfo(string PhoneNr)
        {
            DataBase db = new DataBase();
            DataBase db2 = new DataBase();
            DataSet ds = new DataSet();
            DataSet dstemp = new DataSet();




            string selectStr = "select Name,ChineseName,CellPhone,WeChat from Users  WHERE  convert(nvarchar(255),CellPhone)= '" + PhoneNr + "'";

            ds = db.RunProcReturnDS(selectStr);


            return ds;


        }
        public DataSet EQ_List(string DeptNumber)
        {
            DataBase db = new DataBase();
            DataBase db2 = new DataBase();
            DataSet ds = new DataSet();
            DataSet dstemp = new DataSet();




            string selectStr = "select Flag,设备名称,设备型号,生产厂商,出厂编号,存放位置  from 设备表 where convert(nvarchar(255),所属科室)= '" + DeptNumber + "'";

            ds = db.RunProcReturnDS(selectStr);


            return ds;


        }
        public DataSet RPlist_Caller(string username)
        {
            DataBase db = new DataBase();
            
            DataSet ds = new DataSet();





            string selectStr = "select 设备表.设备名称,报修任务表.故障描述,报修任务表.报修时间,User2.ChineseName,报修任务表.维修进程,User2.WeChat,报修任务表.Flag FROM  报修任务表  JOIN Depts  ON  convert(nvarchar(255),报修任务表.所属科室)=convert(nvarchar(255),Depts.DeptNumber)  JOIN Users as User2  ON  convert(nvarchar(255),报修任务表.执行人)=convert(nvarchar(255),User2.ID)  JOIN 设备表  ON  convert(nvarchar(255),设备表.Flag)=convert(nvarchar(255),报修任务表.设备Flag)   WHERE  convert(nvarchar(255),报修任务表.报修人电话)='" + username + "' and convert(nvarchar(255),报修任务表.维修进程)!= '任务完成' order by 报修任务表.ID desc";

            ds = db.RunProcReturnDS(selectStr);
            ds.Tables[0].Columns[3].ColumnName = "执行人";
          
           







            return ds;


        }
        public DataSet EQ_Task_List(string EQFlag)
        {
            DataBase db = new DataBase();

            DataSet ds = new DataSet();





            string selectStr = "select 设备表.设备名称,报修任务表.故障描述,报修任务表.报修时间,User2.ChineseName,报修任务表.维修进程,User2.WeChat,报修任务表.Flag FROM  报修任务表  JOIN Depts  ON  convert(nvarchar(255),报修任务表.所属科室)=convert(nvarchar(255),Depts.DeptNumber)  JOIN Users as User2  ON  convert(nvarchar(255),报修任务表.执行人)=convert(nvarchar(255),User2.ID)  JOIN 设备表  ON  convert(nvarchar(255),设备表.Flag)=convert(nvarchar(255),报修任务表.设备Flag)   WHERE  convert(nvarchar(255),报修任务表.设备Flag)='" + EQFlag + "' order by 报修任务表.ID desc";

            ds = db.RunProcReturnDS(selectStr);
            ds.Tables[0].Columns[3].ColumnName = "执行人";









            return ds;


        }
        public DataSet RPlist_EGN(string CellPhone)
        {
            DataBase db = new DataBase();

            DataSet ds = new DataSet();


            UserInfo us = new UserInfo();
            us.Init(CellPhone);


            string selectStr = "select 设备表.设备名称,报修任务表.故障描述,报修任务表.报修时间,报修任务表.报修人,报修任务表.维修进程,报修任务表.Flag,Depts.Name FROM  报修任务表  JOIN Depts  ON  convert(nvarchar(255),报修任务表.所属科室)=convert(nvarchar(255),Depts.DeptNumber)  JOIN Users as User1  ON  convert(nvarchar(255),报修任务表.执行人)=convert(nvarchar(255),User1.ID)  JOIN 设备表  ON  convert(nvarchar(255),设备表.Flag)=convert(nvarchar(255),报修任务表.设备Flag)   WHERE  (convert(nvarchar(255),报修任务表.报修人)='" + us.ChineseName + "' or convert(nvarchar(255),User1.CellPhone)='" + CellPhone + "') and convert(nvarchar(255),报修任务表.维修进程)!= '任务完成' order by 报修任务表.ID desc";

            ds = db.RunProcReturnDS(selectStr);
     









            return ds;


        }
        public DataSet RPlistByCallPerson_Other(string username)
        {
            DataBase db = new DataBase();

            DataSet ds = new DataSet();


            string selectStr = "select 任务表.ID,任务表.报修编号,其它设备表.设备名称,其它设备表.资产编号,任务表.维修进程,任务表.资产编号 FROM 其它设备表 JOIN 任务表 ON  convert(nvarchar(255),任务表.报修编号)=convert(nvarchar(255),其它设备表.资产编号) WHERE convert(nvarchar(255),任务表.报修人)= '" + username + "'";

            ds = db.RunProcReturnDS(selectStr);
            return ds;


        }



        public string Add_Spare(string TaskFlag, string Name, string Type, string SrNr, string Price, string Replace_Date, string Hospital)
        {

            DataBase db = new DataBase();
            int result = db.RunProc("insert into 配件表(任务Flag,配件名称,型号,序列号,价格,更换日期,所属医院) values('" + TaskFlag + "','" + Name + "','" + Type + "','" + SrNr + "','" + Price + "','" + Replace_Date + "','" + Hospital + "')");
            return result.ToString();

        }









        public DataSet Repair_Log_List(string rp_nmr)
        {
            DataBase db = new DataBase();

            DataSet ds = new DataSet();


            string selectStr = "select ID,报修编号,维修记录号,是否有图片,是否有音频,记录内容,记录人,记录时间,记录类型 FROM 维护记录表 WHERE convert(nvarchar(255),报修编号)= '" + rp_nmr + "' order by ID";

            ds = db.RunProcReturnDS(selectStr);
            return ds;


        }





        public DataSet Get_Phone_list_By_Department(string dept)
        {

            DataBase db = new DataBase();

            DataSet ds = new DataSet();


            string selectStr = "select * FROM 通讯录 WHERE convert(nvarchar(255),科室)= '" + dept + "'";

            ds = db.RunProcReturnDS(selectStr);
            return ds;





        }
        public DataSet Get_Phone_list_By_Name(string name)
        {

            DataBase db = new DataBase();

            DataSet ds = new DataSet();


            string selectStr = "select * FROM 通讯录 WHERE convert(nvarchar(255),姓名) LIKE  '%'+'" + name + "'+'%'";

            ds = db.RunProcReturnDS(selectStr);
            return ds;





        }
        public DataSet Get_Info_list_By_Phone(string phone)
        {

            DataBase db = new DataBase();

            DataSet ds = new DataSet();


            string selectStr = "select * FROM 通讯录 WHERE convert(nvarchar(255),电话)= '" + phone + "'";

            ds = db.RunProcReturnDS(selectStr);
            return ds;





        }



        public string Add_BPM(string department, string Nr, string factory, string other)
        {

            DataBase db = new DataBase();
            db.RunProc("insert into 血压计表(所属科室,编号,生产厂家,设备状态,备注) values('" + department + "','" + Nr + "','" + factory + "','正常使用中','" + other + "')");
            return "ok";

        }


        public string Add_BPM_Repair(string Nr)
        {

            DataBase db = new DataBase();
            db.RunProc("update 血压计表 set 设备状态='已送修'where 编号='" + Nr + "'");
            return "ok";

        }



        public string Add_BPM_Repair_Log(string Nr, string SendTime, string FinishTIme, string Enginner, string Log, string spare, string Take)
        {



            DataBase db = new DataBase();
            db.RunProc("insert into 血压计维修表(编号,送修时间,维修完成时间,维修人,维修记录,更换配件,是否领取) values('" + Nr + "','" + SendTime + "','" + FinishTIme + "','" + Enginner + "','" + Log + "','" + spare + "','" + Take + "')");

            db.RunProc("update 血压计表 set 设备状态='维修完成等待领取'where 编号='" + Nr + "'");
            return "ok";

        }


        public string BPM_Repair_Finish(string Nr)
        {



            DataBase db = new DataBase();
            // db.RunProc("insert into 血压计维修表(编号,送修时间,维修完成时间,维修人,维修记录,更换配件,是否领取) values('" + Nr + "','" + SendTime + "','" + FinishTIme + "','" + Enginner + "','" + Log + "','" + spare + "','" + Take + "')");

            db.RunProc("update 血压计表 set 设备状态='正常'where 编号='" + Nr + "'");
            return "ok";

        }

        /// <summary>
        /// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// </summary>
        /// <param name="bxbh"></param>
        /// <param name="zcbh"></param>
        /// <param name="name"></param>
        /// <param name="type"></param>
        /// <param name="sn"></param>
        /// <param name="gzxx"></param>
        /// <param name="bxr"></param>
        /// <param name="deptm"></param>













        public DataSet Get_Department_List()
        {
            DataBase db = new DataBase();

            DataSet ds = new DataSet();


            //string selectStr = "select * from 科室表 where convert(nvarchar(255),hospital)= '" + hospital + "'";
            string selectStr = "select * from 科室表";

            ds = db.RunProcReturnDS(selectStr);
            return ds;
        }





        //工程师维修任务表
        public DataSet Engineer_Task_list(string username)
        {
            DataBase db = new DataBase();

            DataSet ds = new DataSet();


            // string selectStr = "select * from 维修表 where convert(nvarchar(255),报修人)= '" + bxr + "'";
            string selectStr = "select 维修表.报修编号,设备表.设备名称,设备表.资产编号,设备表.所属科室,维修表.维修进程,维修表.是否完成,维修表.报修时间,维修表.故障现象 from 维修表  JOIN 设备表 ON  convert(nvarchar(255),维修表.资产编号)=convert(nvarchar(255),设备表.资产编号) WHERE convert(nvarchar(255),设备表.负责工程师)= '" + username + "' AND convert(nvarchar(255),维修表.是否完成)= '否'";

            ds = db.RunProcReturnDS(selectStr);
            return ds;


        }

        public string DeleteRP(string RPNo)
        {

            DataBase dbs = new DataBase();
            string selectStr = "delete from 任务表 where 报修编号='" + RPNo + "'";
            dbs.RunProc(selectStr);
            dbs.Dispose();
            return "ok";


        }




















































        public string GetDeptm(string Name)
        {
            DataBase db = new DataBase();

            DataSet ds = new DataSet();


            string selectStr = "select * from 用户表 where convert(nvarchar(255),用户ID)= '" + Name + "'";

            ds = db.RunProcReturnDS(selectStr);
            if (ds.Tables[0].Rows.Count > 0)

                return ds.Tables[0].Rows[0][3].ToString().Trim();
            else
                return "0";

        }

       

        public void UpdateBindData(string name, string UserID, string ChanelID)
        {
            DataBase dbs = new DataBase();

            string selectStr = "update 用户表 set UserID='" + UserID + "',ChanelID='" + ChanelID + "'where convert(nvarchar(255),用户ID)='" + name + "'";

            dbs.RunProc(selectStr);

            dbs.Dispose();

        }




























    }


}
